package com.sqfw.project.wpReport.controller;

import com.sqfw.common.utils.poi.ExcelUtil;
import com.sqfw.framework.aspectj.lang.annotation.Log;
import com.sqfw.framework.aspectj.lang.enums.BusinessType;
import com.sqfw.framework.web.controller.BaseController;
import com.sqfw.framework.web.domain.AjaxResult;
import com.sqfw.framework.web.page.TableDataInfo;
import com.sqfw.project.wp.domain.WpInfo;
import com.sqfw.project.wpReport.domain.WpInfoSummary;
import com.sqfw.project.wpReport.domain.dto.WpInfoSummaryDTO;
import com.sqfw.project.wpReport.service.IWpInfoSummaryService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * 工单汇总表Controller
 *
 * @author lx
 * @date 2023-07-10
 */
@Api(tags = "工单列表")
@RestController
@RequestMapping("/wpReport/wpInfoSummary")
public class WpInfoSummaryController extends BaseController {

    @Autowired
    private IWpInfoSummaryService wpInfoSummaryService;

    /**
     * 工单汇总表统计
     *
     * @param wpInfoSummaryDTO
     * @return
     */
    @PreAuthorize("@ss.hasPermi('getWpInfoSummaryList')")
    @GetMapping("/getWpInfoSummaryList")
    public AjaxResult getWpInfoSummaryList(WpInfoSummaryDTO wpInfoSummaryDTO) {

        List<WpInfoSummary> wpInfoSummaryList = wpInfoSummaryService.getWpInfoSummaryList(wpInfoSummaryDTO);
        return AjaxResult.success(wpInfoSummaryList);
    }


    /**
     * 导出工单汇总表列表
     */
    @Log(title = "工单汇总表", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('wpInfoSummary:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, WpInfoSummaryDTO wpInfoSummaryDTO) {
        List<WpInfoSummary> list = wpInfoSummaryService.getWpInfoSummaryList(wpInfoSummaryDTO);
        ExcelUtil<WpInfoSummary> util = new ExcelUtil<WpInfoSummary>(WpInfoSummary.class);
        util.exportExcel(response, list, "工单汇总表数据");
    }

    /**
     * 查询统计工单列表
     *
     * @param wpInfo
     * @return
     */
    @PreAuthorize("@ss.hasPermi('getWpInfoCountList')")
    @GetMapping("/getWpInfoCountList")
    public TableDataInfo getWpInfoCountList(WpInfo wpInfo) {
        startPage();
        List<WpInfo> list = wpInfoSummaryService.getWpInfoCountList(wpInfo);
        return getDataTable(list);
    }


}
